@extends('admin.base')


@section('content')
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            商品类别表
            <small>GoodsType</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="{{URL('/')}}}"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">商品类别</a></li>
            <li class="active">列表</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title"><i class="fa fa-th"></i>商品分类信息管理</h3>
                        &nbsp; <button class="btn btn-sm btn-primary" onclick="window.location='{{URL('admin/category/create')}}'">添加父类别</button>
                    </div><!-- /.box-header -->
                    <div class="box-body">
                        <table class="table table-bordered">
                            <tr>
                                <th style="width:60px">ID号</th>
                                <th>名称</th>
                                <th>父类ID</th>
                                <th>添加时间</th>
                                <th style="width: 170px">操作</th>
                            </tr>
                            @foreach($list as $vo)
                                <tr>
                                    <td>{{ $vo->cate_id }}</td>
                                    <td><?php echo str_repeat("&nbsp;",4*$vo->level);?>{{ $vo->cate_name }}</td>
                                    <td>{{ $vo->cate_pid }}</td>
                                    <td>{{ $vo->created_at }}</td>
                                    <td>
                                        <button class="btn btn-xs btn-primary" onclick="cateDel({{$vo->cate_id}})" >删除</button>
                                        <a href="{{url('admin/category/'.$vo->cate_id.'/edit')}}"><button class="btn btn-xs btn-primary" >编辑</button></a>
                                        <button class="btn btn-xs btn-primary" onclick="window.location='{{URL('/admin/category')}}/{{ $vo->cate_id }}'">添加子类</button>
                                    </td>
                                </tr>
                            @endforeach

                        </table>
                    </div><!-- /.box-body -->
                </div><!-- /.box -->

            </div><!-- /.col -->
        </div><!-- /.row -->
    </section><!-- /.content -->

@endsection


        <script type="text/javascript">
        function cateDel(cate_id){
            //询问框
            layer.confirm('是否确认删除？', {
                btn: ['确定','取消'] //按钮
            }, function(){
                $.post("{{url('admin/category')}}/"+cate_id,{'_method':'delete','_token':"{{csrf_token()}}"},function(data){
                    if(data.status == 0){
                        location.href = location.href;
                        layer.msg(data.msg, {icon: 6});
                    }else{
                        location.href = location.href;
                        layer.msg(data.msg, {icon: 5});
                    }
                });

            }, function(){

            });
        }
    </script>
